#include <iostream>
#include <queue>
#include <map>
using namespace std;

int main(){
	int m,n,ans=0;
	cin>>m>>n;
	queue<int> q;
	map<int,int> ma;
	for(int i=0;i<n;i++){
		int l;
		cin>>l;
		if(ma[l] == 1)
			continue;
		ma[l] = 1;
		ans++;
		if(q.size() >= m){
			ma[q.front()] = 0;
			q.pop();
			q.push(l);
		}
		else
			q.push(l);
	}
	cout<<ans;
	return 0;
}
